package auleiy.halo.client;

import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.*;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class HaloModels {
    public static final ModelPart CircleHalo;
    public static final ModelPart ThickCircleHalo;

    static {
        CircleHalo = CircleHalo();
        ThickCircleHalo = ThickCircleHalo();
    }

    public static ModelPart ThickCircleHalo() {
        MeshDefinition meshDef = new MeshDefinition();
        PartDefinition partDef = meshDef.getRoot();

        partDef.addOrReplaceChild("r0", CubeListBuilder.create()
                .texOffs(0, 0)
                .addBox(-9.4142f, -0.5F, 4.0f, 2.8284F, 0.5F, 0.25F, new CubeDeformation(0.0F))
                .texOffs(0, 0)
                .addBox(-4.8358f, -0.5F, 6.0f, 0.25F, 0.5F, 2.8284F, new CubeDeformation(0.0F))
                .texOffs(0, 0)
                .addBox(-9.4142f, -0.5F, 10.5784f, 2.8284F, 0.5F, 0.25F, new CubeDeformation(0.0F))
                .texOffs(0, 0)
                .addBox(-11.4142f, -0.5F, 6.0f, 0.25F, 0.5F, 2.8284F, new CubeDeformation(0.0F)), PartPose.ZERO);
        partDef.addOrReplaceChild("r1", CubeListBuilder.create()
                .texOffs(0, 0)
                .addBox(-4.0F, -0.5F, -1.7574F, 0.25F, 0.5F, 2.8284F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-7.8284f, 0.0F, 8.0711f, 0.0F, -0.7854F, 0.0F));
        partDef.addOrReplaceChild("r2", CubeListBuilder.create()
                .texOffs(0, 0)
                .addBox(-0.8284F, -0.5F, 2.3357F, 2.8284F, 0.5F, 0.25F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-9.0f, 0.0F, 7.5858f, 0.0F, -0.7854F, 0.0F));
        partDef.addOrReplaceChild("r3", CubeListBuilder.create()
                .texOffs(0, 0)
                .addBox(2.9216F, -0.5F, -2.5858F, 0.25F, 0.5F, 2.8284F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-8.6569f, 0.0F, 8.4142f, 0.0F, -0.7854F, 0.0F));
        partDef.addOrReplaceChild("r4", CubeListBuilder.create()
                .texOffs(0, 0)
                .addBox(-1.6568F, -0.5F, -4.5858F, 2.8284F, 0.5F, 0.25F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-8.6569f, 0.0F, 8.4142f, 0.0F, -0.7854F, 0.0F));

        return LayerDefinition.create(meshDef, 16, 16).bakeRoot();
    }

    public static ModelPart CircleHalo() {
        MeshDefinition meshDef = new MeshDefinition();
        PartDefinition partDef = meshDef.getRoot();

        partDef.addOrReplaceChild("grid", CubeListBuilder.create()
                .texOffs(0, 0)
                .addBox(-9.4142F, -0.5F, 4.0F, 2.8284F, 0.5F, 1.0F, new CubeDeformation(0.0F))
                .texOffs(0, 0)
                .addBox(-5.5858F, -0.5F, 6.0F, 1.0F, 0.5F, 2.8284F, new CubeDeformation(0.0F))
                .texOffs(0, 0)
                .addBox(-9.4142F, -0.5F, 9.8284F, 2.8284F, 0.5F, 1.0F, new CubeDeformation(0.0F))
                .texOffs(0, 0)
                .addBox(-11.4142F, -0.5F, 6.0F, 1.0F, 0.5F, 2.8284F, new CubeDeformation(0.0F)), PartPose.ZERO);

        partDef.addOrReplaceChild("rot0", CubeListBuilder.create()
                .texOffs(0, 0)
                .addBox(-4.0F, -0.5F, -2.0F, 1.0F, 0.5F, 2.8284F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-8.0F, 0.0F, 8.2426F, 0.0F, -0.7854F, 0.0F));

        partDef.addOrReplaceChild("rot1", CubeListBuilder.create()
                .texOffs(0, 0)
                .addBox(-0.8284F, -0.5F, 3.0F, 2.8284F, 0.5F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-8.0F, 0.0F, 6.5857F, 0.0F, -0.7854F, 0.0F));

        partDef.addOrReplaceChild("rot2", CubeListBuilder.create()
                .texOffs(0, 0)
                .addBox(3.0F, -0.5F, -2.0F, 1.0F, 0.5F, 2.8284F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-8.8284F, 0.0F, 7.4142F, 0.0F, -0.7854F, 0.0F));

        partDef.addOrReplaceChild("rot3", CubeListBuilder.create()
                .texOffs(0, 0)
                .addBox(-0.8284F, -0.5F, -4.0F, 2.8284F, 0.5F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-8.8284F, 0.0F, 7.4142F, 0.0F, -0.7854F, 0.0F));

        return LayerDefinition.create(meshDef, 16, 16).bakeRoot();
    }
}
